package com.kkb.service.impl;

import com.kkb.domain.AjaxResult;
import com.kkb.mapper.SkGoodsMapper;
import com.kkb.pojo.*;
import com.kkb.service.SkGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.ArrayList;
import java.util.List;

@Service
public class SkGoodsServiceImpl implements SkGoodsService {

    @Autowired
    private SkGoodsMapper skGoodsMapper;

    //商品列表
    @Override
    public List<SkGoods> selectByExample() {
        SkGoodsExample example = new SkGoodsExample();
        List<SkGoods> skGoods = skGoodsMapper.selectByExample(example);
        return skGoods;
    }

    //根据ID查询分类信息是否存在
    @Override
    public String checkDeptNameUnique(Integer goodsId){
        return null;
    }

    //根据分类名称查询
    @Override
    public String checkDeptNameUnique(String goodsName) {
        return null;
    }

    //新增
    @Override
    public AjaxResult insert(SkGoods record) {
        int insert = skGoodsMapper.insert(record);
        if (insert > 0){
            return AjaxResult.success();
        }else {
            return AjaxResult.error();
        }
    }

    //修改
    @Override
    public AjaxResult updateById(SkGoods record) {
        int updateskGoods = skGoodsMapper.updateByPrimaryKey(record);
        if (updateskGoods > 0){
            return AjaxResult.success();
        }else {
            return AjaxResult.error();
        }
    }

    //根据id查询
    @Override
    public SkGoods selectGoodsById(Long goodsId) {
        return skGoodsMapper.selectByPrimaryKey(goodsId);
    }

    /**
     * 删除
     * @param recordId
     * @return
     */
    @Override
    public AjaxResult deletegoodsById(Long recordId) {
        int deleteById = skGoodsMapper.deleteByPrimaryKey(recordId);
        if (deleteById > 0){
            return AjaxResult.success();
        }else {
            return AjaxResult.error();
        }
    }

    @Override
    public Long selectCount(Integer categoryId) {
        return null;
    }

    @Override
    public List<Ztree> selectGoodsTree(SkGoods skGoods) {
        return null;
    }


}
